﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using SCRUM.Core.BusinessObjects;
using SCRUM.Core.DataProviders;

namespace SCRUM.Core.DAO
{
    /// <summary>
    /// Data access object for widget
    /// </summary>
    public static class DAOWidget
    {
        /// <summary>
        /// Gets the list of widgets for specified column.
        /// </summary>
        /// <param name="column">The column that contains widgets.</param>
        /// <returns>List of widgets in specified column.</returns>
        public static IList<Widget> GetWidgets(WidgetColumn column)
        {
            return ProviderFactory.Provider.GetWidgets(column);
        }

        /// <summary>
        /// Gets the widget by ID.
        /// </summary>
        /// <param name="id">The identifier.</param>
        /// <returns>Widget with a specified ID.</returns>
        public static Widget GetWidgetByID(int id)
        {
            return ProviderFactory.Provider.GetWidgetByID(id);
        }

        /// <summary>
        /// Creates the new instance of widget for current user
        /// </summary>
        /// <param name="widget">The widget.</param>
        public static void CreateNewWidget(int widgetTypeID, int order, int columnID)
        {
            ProviderFactory.Provider.CreateNewWidget(widgetTypeID, order, columnID, MembershipProviders.MembershipProviderFactory.MembershipProvider.GetUser().ID);
        }

        /// <summary>
        /// Deletes the specified global widget base.
        /// </summary>
        /// <param name="widget">The widget.</param>
        public static void DeleteWidget(Widget widget)
        {
            ProviderFactory.Provider.DeleteWidget(widget);
        }

        /// <summary>
        /// Changes the order of the widget in column. 
        /// </summary>
        /// <param name="widget">Widget to change order</param>
        /// <param name="up">Direction, if true then increase order, else decrease</param>
        public static void ChangeWidgetOrder(Widget widget, bool up)
        {
            ProviderFactory.Provider.ChangeWidgetOrder(widget, up);
        }

        /// <summary>
        /// Copies the widgets into column.
        /// </summary>
        /// <param name="widgetsToCopy">The widgets to copy.</param>
        /// <param name="columnID">The column ID.</param>
        /// <param name="userID">The user ID.</param>
        public static void CopyWidgetsIntoColumn(IList<Widget> widgetsToCopy, int columnID, int userID)
        {
            ProviderFactory.Provider.CopyWidgetsIntoColumn(widgetsToCopy, columnID, userID);
        }
    }
}
